package o;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.FrameLayout.LayoutParams;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView.a;
import androidx.recyclerview.widget.RecyclerView.s;
import com.huawei.appgallery.forum.base.card.bean.Section;
import java.util.ArrayList;
import java.util.List;
import o.bun.d;
import o.bun.e;

public class bum extends a {
    private List<Section> ˊ = new ArrayList();
    private final Context ˋ;
    private int ˎ;
    private int ॱ;

    public bum(Context context) {
        this.ˋ = context;
        ॱ();
    }

    @NonNull
    public s ˎ(@NonNull ViewGroup viewGroup, int i) {
        s o_bvk = new bvk(LayoutInflater.from(viewGroup.getContext()).inflate(d.ᐝ, viewGroup, false));
        if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
            o_bvk.ˊ.setLayoutDirection(1);
        }
        return o_bvk;
    }

    public void ॱ(@NonNull s sVar, int i) {
        if ((sVar instanceof bvk) && this.ˊ != null && this.ˊ.size() > 0) {
            ˎ((bvk) sVar, i, this.ˊ);
        }
    }

    private void ˎ(bvk o_bvk, int i, List<Section> list) {
        if (list != null && list.size() > 0) {
            final Section section = (Section) list.get(i);
            if (section != null) {
                eqx.ˏ(o_bvk.ᐝॱ, section.ॱ(), "app_default_icon");
                o_bvk.ॱˋ.setText(section.ˏ());
                o_bvk.ॱᐝ.setOnClickListener(new evx(this) {
                    final /* synthetic */ bum ˊ;

                    public void ˋ(View view) {
                        cil.ˋ(this.ˊ.ˋ, new cim.a().ˊ(section.ॱॱ()).ˋ());
                        bvf.ˋ().ˊ(this.ˊ.ˋ, section, null);
                    }
                });
                o_bvk.ᐝॱ.setOnClickListener(new evx(this) {
                    final /* synthetic */ bum ˊ;

                    public void ˋ(View view) {
                        cil.ˋ(this.ˊ.ˋ, new cim.a().ˊ(section.ॱॱ()).ˋ());
                        bvf.ˋ().ˊ(this.ˊ.ˋ, section, null);
                    }
                });
                o_bvk.ᐝॱ.setContentDescription(section.ˏ());
            }
            int ॱ = ((azb.ॱ(this.ˋ) - (this.ˎ * (this.ॱ + 1))) - this.ˋ.getResources().getDimensionPixelSize(e.ˏ)) / this.ॱ;
            MarginLayoutParams marginLayoutParams = (MarginLayoutParams) o_bvk.ˊ.getLayoutParams();
            if (marginLayoutParams != null) {
                marginLayoutParams.width = ॱ;
                ˎ(i, marginLayoutParams);
                o_bvk.ˊ.setLayoutParams(marginLayoutParams);
                o_bvk.ᐝॱ.setLayoutParams(new LayoutParams(ॱ, ॱ));
            }
        }
    }

    private void ˎ(int i, MarginLayoutParams marginLayoutParams) {
        marginLayoutParams.setMarginEnd(0);
        if (i == 0) {
            marginLayoutParams.setMarginStart(azb.ˊ(this.ˋ));
            return;
        }
        if (i == ˏ() - 1) {
            marginLayoutParams.setMarginEnd(azb.ˊ(this.ˋ));
        }
        marginLayoutParams.setMarginStart(azb.ˊ(this.ˋ));
    }

    public void ˎ(List<Section> list) {
        this.ˊ = list;
        ˊ();
    }

    public int ˏ() {
        return this.ˊ == null ? 0 : this.ˊ.size();
    }

    private void ॱ() {
        if (epv.ˏॱ(this.ˋ)) {
            this.ॱ = 7;
        } else if (epv.ʼ(this.ˋ)) {
            this.ॱ = 3;
        } else {
            this.ॱ = 6;
        }
        this.ˎ = azb.ˊ(this.ˋ);
    }
}
